<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
	<ui:composition template="/templates/padrao.xhtml">
		<ui:define name="barraTitulo">Cadastro de Servi&ccedil;o:</ui:define>
		 
		<ui:define name="conteudo">
			<p:dialog header="Pesquisa Cliente" widgetVar="modalPsqCliente" onCloseUpdate="form" modal="true" height="480" width="600" id="boxPesquisarCliente">
				<h:form id="formPesquisaCliente">
					<p:tabView id="tabView">
						<p:tab title="Pesquisa de Cliente">
							<fieldset>
								<h:panelGrid columns="2" columnClasses="alinhaEsq width70">
									<h:column>
										<h:outputText value="Nome:" styleClass="textfield" />
									</h:column>
									<h:column>
										<h:inputText value="#{controleServico.pesquisaNomeCliente}"  size="35" styleClass="textfield" />
									</h:column>
									<h:column>
										<h:outputText value="CPF / CNPJ:" styleClass="textfield" />
									</h:column>
									<h:column>
										<h:inputText value="#{controleServico.pesquisaCPFCNPJCliente}"  size="20" styleClass="textfield" />
									</h:column>
						
									
								</h:panelGrid>
								
								
							</fieldset>
							<p:commandLink action="#{controleServico.pesquisarCliente}" styleClass="alinhaDir" update=":listaPesquisaCliente">
								<h:graphicImage url="/images/botoes/btnPesquisar.png" class="btnAcoes"/>
							</p:commandLink>
						</p:tab>
					</p:tabView>
				</h:form>
				<br/>
				<br/>
				<h:form id="listaPesquisaCliente">
					<p:dataTable value="#{controleServico.listaCliente}" 
					             id="id_ListaCliente"
					             var="cliente" 
					             paginator="true" 
					             rows="5" 
					             dynamic="true" 
					             rendered="#{not empty controleServico.listaCliente}" 
								 firstPageLinkLabel="Primeiro"
					             previousPageLinkLabel="Anterior"
					             nextPageLinkLabel ="Pr&oacute;ximo"
					             lastPageLinkLabel="&Uacute;ltima"
					             emptyMessage="Nenhum resgistro encontrado"
					             errorMessage="Ocorreu um erro"
	    			             selection="#{controleServico.servico.cliente}" 
					             selectionMode="single" >
						<p:column>
							<f:facet name="header">
								<h:outputText value="Nome" />
							</f:facet>
							<h:outputText value="#{cliente.nome}" />
						</p:column>
						<p:column>	
						<f:facet name="header">
								<h:outputText value="CPF / CNPJ:" />
							</f:facet>
							<h:outputText value="#{cliente.CPF_CNPJ}" />
						</p:column>	
						<p:column resizable="true" styleClass="width20">
							<f:facet name="header">
								<h:outputText value="A&ccedil;&atilde;o" /> 
							</f:facet>
                            <h:commandLink onclick="modalPsqCliente.hide()">
								<p:graphicImage url="/images/marcadores/add.png" alt="Seleciona Cliente"/>
								<f:setPropertyActionListener target="#{controleServico.servico.cliente}" value="#{cliente}" />
                            </h:commandLink>
                     	</p:column>
					</p:dataTable>
				</h:form>
			</p:dialog>   
			<h:form id="formServico">
				<p:dialog header="Mensagem" id="dialog1" widgetVar="dialog" fixedCenter="true" modal="true" visible="#{facesContext.maximumSeverity != null}">
				   <p:messages/>                     
				</p:dialog>
				<p:tabView id="divTabView">
					<p:tab title="Cadastro">
						<h:panelGrid columns="3" columnClasses="width150 alinhaDir, width500">
							<h:outputText value=""/>
							<h:outputText value="Os campos com asterisco (*) s&atilde;o de preenchimento obrigat&oacute;rio." styleClass="campoObrigatorio" />
							<h:outputText value=""/>
							
							<h:outputText value=""/>
							<h:column>
								<p:panel header="Tipo Servi&ccedil;o">
									<h:panelGrid columns="3" columnClasses="width200,  , width200" >
										<h:column />									
											<p:pickList value="#{controleServico.listaTipoServicos}" 
												var="tipoServico" 
												itemLabel="#{tipoServico.descricao}" 
												itemValue="#{tipoServico}" 
												converter="converteTipoServico"
												iconOnly="true">
												<f:facet name="sourceCaption">Todos</f:facet>  
												<f:facet name="targetCaption">Selecionados</f:facet> 
											</p:pickList>
										<h:column />
									</h:panelGrid>					
								</p:panel>
							</h:column>
							<h:outputText value=""/>
							
							<h:outputText value="Descri&ccedil;&atilde;o:" styleClass=""/>
							<h:column>
								<h:inputText  value="#{controleServico.servico.descricao}" requiredMessage="Campo [DESCRICAO] obrigat&oacute;rio" size="60"/>
								<h:outputText value="(*)" styleClass="campoObrigatorio" />					
							</h:column>
							<h:outputText value=""/>
							
							<h:outputText value="Cliente:" styleClass="alinhaDir"/>							
							<h:column>
								<h:outputText value="#{controleServico.servico.cliente.nome}"/>&nbsp;
								<p:commandLink oncomplete="modalPsqCliente.show()">
									<h:graphicImage url="/images/botoes/btnSelecionar.png" styleClass="iconesLaterais" />
								</p:commandLink>		
								<h:outputText value="(*)" styleClass="campoObrigatorio" />														
							</h:column>
							<h:outputText value=""/>							
							
							<h:outputText value="Observa&ccedil;&atilde;o:" styleClass=""/>
							<h:column>
								<p:inputTextarea style="width:300px;height:100px;" effectDuration="400" value="#{controleServico.servico.observacao}" />  
								<h:outputText value=""/>
							</h:column>						
							<h:outputText value=""/>
							<h:outputText value="&nsbp; UF:&nbsp;" styleClass=""/>
							<h:selectOneMenu value="#{controleServico.servico.uf}" requiredMessage="Campo [UF] obrigat&oacute;rio" required="true" >  
			                    <f:selectItems value="#{controleServico.UFS}" var="UF" itemLabel="#{UF}" itemValue="#{UF}" />
							</h:selectOneMenu>
							<h:outputText value=""/>
							
							<h:outputText value="Data Inicial:" styleClass=""/>
							<h:column >
								<p:calendar value="#{controleServico.servico.dataAnuncio}" mode="popup" pattern="dd/MM/yyyy" requiredMessage="Campo [DATA INICIAL] obrigat&oacute;rio" />
								<h:outputText value="(*) " styleClass="campoObrigatorio" />							
								<h:outputText value="  Data T&eacute;rmino:" styleClass=""/>							
								<p:calendar value="#{controleServico.servico.dataFimAnuncio}" mode="popup" pattern="dd/MM/yyyy" requiredMessage="Campo [DATA TÉRMINO] obrigat&oacute;rio" />
								<h:outputText value="(*)" styleClass="campoObrigatorio" />
							</h:column>
							<h:outputText value="" />
							
							<h:outputText value="Imagens" styleClass=""/>
							<p:fileUpload fileUploadListener="#{controleServico.fileUpload}"  multiple="true"  auto="true" label="Uploads" allowTypes="*.jpg;*.png;*.gif;" description="Images"/>
								<ui:repeat var="imagemServico" value="#{controleServico.servico.imagensServicos}">
									<img src="#{controleServico.caminho}"></img>
							</ui:repeat>
							 <h:outputText value=""/>
							
							
							
						</h:panelGrid>
					</p:tab>
				</p:tabView>
				<h:commandLink action="#{controleServico.gravar}" styleClass="alinhaDir">
					<h:graphicImage url="/images/botoes/btnGravar.png" class="btnAcoes"/>
				</h:commandLink>				
				<h:commandLink action="#{controleServico.limpar}">
					<h:graphicImage url="/images/botoes/btnLimpar.png" class="btnAcoes"/>
					<f:ajax render="divTabView"/>
				</h:commandLink>
				<h:outputLink value="manutencao.jsf">
					<h:graphicImage url="/images/botoes/btnPesquisar.png" class="btnAcoes"/>
				</h:outputLink>	
				
			</h:form>
		</ui:define>
	</ui:composition>
</html>



